package com.dreamer.service.pyramid;

import com.dreamer.domain.pyramid.Pyramid;
import com.dreamer.repository.pyramid.PyramidDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ps.mx.otter.utils.SearchParameter;

import java.util.List;

@Service
public class PyramidHandler {

    @Autowired
    private PyramidDAO pyramidDAO;

    @Transactional
    public Pyramid saveOrupdate(Pyramid pyramid){
        Pyramid instance = pyramidDAO.merge(pyramid);
        LOG.debug("新增活动成功"+instance);
        return pyramid;
    }

    @Transactional
    public void remove(Pyramid pyramid) {
        pyramidDAO.delete(pyramid);
        LOG.debug("删除活动成功");
    }

    private final Logger LOG = LoggerFactory.getLogger(getClass());

    public Pyramid findById(Integer integer) {
        return  pyramidDAO.findById(integer);
    }

    public List<Pyramid> searchAllByPage(SearchParameter<Pyramid> parameter) {
        return pyramidDAO.searchAllByPage(parameter);
    }

    public List<Pyramid> findAll(){
        return pyramidDAO.findAll();
    }

}
